<template>
    <el-dialog :visible.sync="showPdfView" style="margin:20px" :title="title" fullscreen :close-on-click-modal="false" append-to-body :z-index="50000" :close-on-press-escape="false">
        <div style="width: 100%;">
            <iframe v-if="pdfType" class="course-file-iframe"
                    :src="url" width="100%" :style="{'height': BodyH + 'px'}"></iframe>
            <img v-if="!pdfType" :src="url" fit="contain" style="width: 100%;height: 100%" />
        </div>
    </el-dialog>
</template>

<script>
    export default {
        props: {
            url: { type: String, default: '' },
            pdfType: { type: Boolean, default: true },
            title: { type: String, default: '预览文件' }
        },
        data() {
            return {
                showPdfView: false,
                BodyH: window.innerHeight - 140
            };
        },
        mounted() {
            //this.getOrgData();
            var _this = this;
            window.onresize = () => {
                return (() => {
                    _this.BodyH = window.innerHeight - 140;
                })();
            };
        },
        beforeDestroy() {
            window.onresize = null;
        },
        methods: {
            show() {
                this.showPdfView = true;
            },
        },
        template: '#template'
    };
</script>
